import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class Solution {
    int[] nums;
    int[] original;

    public Solution(int[] nums) {
        this.nums = nums;
        this.original = new int[nums.length];
        System.arraycopy(nums, 0, original, 0, nums.length);
    }

    public int[] reset() {
        System.arraycopy(original, 0, nums, 0, nums.length);
        return nums;
    }

    public int[] shuffle() {
        int[] shuffled = new int[nums.length];
        List<Integer> list = new ArrayList<Integer>();
        for (int i = 0; i < nums.length; ++i) {
            list.add(nums[i]);
        }
        Random random = new Random();
        for (int i = 0; i < nums.length; ++i) {
            int j = random.nextInt(list.size());
            shuffled[i] = list.remove(j);
        }
        System.arraycopy(shuffled, 0, nums, 0, nums.length);
        return nums;
    }

    public static void main(String[] args) {
        int[] nums = {1, 2, 3, 4, 5};
        Solution solution = new Solution(nums);
        System.out.println("Original array: ");
        for (int num : nums) {
            System.out.print(num + " ");
        }
        System.out.println();

        // 打乱数组
        solution.shuffle();
        System.out.println("Shuffled array: ");
        for (int num : solution.nums) {
            System.out.print(num + " ");
        }
        System.out.println();

        // 重置数组
        solution.reset();
        System.out.println("Reset array: ");
        for (int num : solution.nums) {
            System.out.print(num + " ");
        }
        System.out.println();
    }
}